<?php use_javascript( "jquery-datepick-".$sf_user->getCulture() );

if ( $lodging->count() )
{
    $dates = array();

    $calendar = $lodging instanceof sfOutputEscaperObjectDecorator ? $lodging->getRawValue()->getLodgingCalendar() : $lodging->getLodgingCalendar();

    if ( !empty( $calendar ) )
        foreach ( explode( ",", $calendar ) as $item )
        {
            array_push( $dates, trim( $item ) );
        }
}

$photoSliderEasing = array( "easein",
                            "easeinout",
                            "easeout",
                            "expoin",
                            "expoout",
                            "expoinout",
                            "bouncein",
                            "bounceout",
                            "bounceinout",
                            "elasin",
                            "elasout",
                            "elasinout",
                            "backin",
                            "backout",
                            "backinout",
                            "linear" );
?>

<div class="navigator body">

    <div class="grid_3"><p>Фотографии</p></div>

    <div class="grid_14"><p><?php echo link_to( "<strong>Щелкино</strong>", '@homepage' ) ?> » <?php echo link_to( "<strong>Квартиры</strong>", '@lodging' ) ?> » <?php echo link_to( "Квартира №".$lodging->getId(), '@description?lodging='.$lodging->getId() ) ?></p></div>

    <div class="grid_5 currency"><?php include_component( 'lodging', 'currency' ) ?></div>

    <div class="grid_3"><p><?php echo link_to( "Новости", '@newsblock' ) ?></p></div>

    <div class="clear"></div>
</div>

<div class="grid_3 my_grid_3">

    <?php if ( $lodging_photos->count() ): ?>
        <?php if ( $lodging_photos->count() > sfConfig::get( 'app_photo_slider_visible' ) ): ?>
        <div class="prevBtn disabled"></div>
        <?php endif ?>
        <div id="photoSlider">
            <ul>
                <?php foreach ( $lodging_photos as $item ): ?>
                    <li><a rel="lodging_photos" class="lodging_photos" href="<?php echo sfConfig::get('app_photos_path_large').$item->getLodgingPhoto() ?>" title="<?php echo $item->getLodgingPhotoName() ?>">
                        <img src="<?php echo sfConfig::get('app_photos_path_mini').$item->getLodgingPhoto() ?>" alt="" />
                    </a></li>
                <?php endforeach ?>
    		</ul>
    	</div>
    	<?php if ( $lodging_photos->count() > sfConfig::get( 'app_photo_slider_visible' ) ): ?>
        <div class="nextBtn"></div>
        <?php endif ?>
        <p>&nbsp;</p>
    <?php endif ?>

    <script type="text/javascript"><!--
    google_ad_client = "pub-9572295614921444";
    /* 120x240, создано 30.04.10 */
    google_ad_slot = "6315828803";
    google_ad_width = 120;
    google_ad_height = 240;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>

</div>

<div class="grid_19 my_grid_19">

    <div class="grid_14 my_grid_14">
        <div id="tabs">
            <ul>
                <li><a href="#tabs-1">Фото</a></li>
                <li><a href="#tabs-2">Календарь</a></li>
            </ul>
            <div id="tabs-1">
                <?php if ( $front_photo->count() ): ?>
                    <img alt="" src="<?php echo sfConfig::get('app_photos_path_view').$front_photo[0]->getLodgingPhoto() ?>" />
                <?php elseif ( $lodging_photos->count() ): ?>
                    <img alt="" src="<?php echo sfConfig::get('app_photos_path_view').$lodging_photos[0]->getLodgingPhoto() ?>" />
                <?php else: ?>
                    <p>&nbsp;</p>
                <?php endif ?>
            </div>
            <div id="tabs-2">
                <div id="rangeDatepick"></div>
                <div class="clear"></div>

                <div class="underCalendar">
                    <div class="underCalendarVacant"></div><span>&nbsp;&ndash;&nbsp;свободно</span>
                    <span>&nbsp;&nbsp;&nbsp;</span>
                    <div class="underCalendarBusy"></div><span>&nbsp;&ndash;&nbsp;занято</span>
                </div>
                <div class="clear"></div>
            </div>
        </div>
    </div>

    <div class="grid_5 my_grid_5">
        <?php include_component( 'lodging', 'descriptionPics', array( 'my_comfort' => $lodging->getLodgingComfort() ) ) ?>

        <?php include_partial( 'lodging/summary', array( 'lodging' => $lodging ) ) ?>
        <!--p>&nbsp;</p>

        <input type="button" class="reserve" value="Забронировать" /-->
    </div>

    <div class="clear"></div>
    <p>&nbsp;</p>

    <div class="grid_19 text_text">
        <?php if ( $lodging->count() ): ?>
            <?php echo $lodging instanceof sfOutputEscaperObjectDecorator ? $lodging->unescape( $lodging->getLodgingDescription() ) : $lodging->getLodgingDescription() ?>
        <?php endif ?>
    </div>

    <div class="clear"></div>
    <p>&nbsp;</p>

</div>

<div class="grid_3 my_grid_3">

    <div class="grid_3">
        <?php include_component( 'welcome', 'newsblock' ) ?>
    </div>

    <script type="text/javascript"><!--
    google_ad_client = "pub-9572295614921444";
    /* 120x240, создано 30.04.10 */
    google_ad_slot = "6315828803";
    google_ad_width = 120;
    google_ad_height = 240;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>

</div>

<div class="clear"></div>

<script language="javascript" type="text/javascript">

    var dates = [ <?php echo empty( $dates ) ? "" : "'".implode( "','", $dates )."'" ?> ];

    function disableDatepick() {
    	$("#rangeDatepick").datepick('disable');

    	$(".datepick-disabled").height( $(".datepick-disabled").height() - $(".datepick-links").outerHeight() );
    	$(".datepick-disabled").css( 'top', $(".ui-tabs-nav").outerHeight() + 2 + $(".datepick-links").outerHeight() + "px" );
    	$(".datepick-disabled").css( 'opacity', 0 );
    }

    $(function() {

        $('#tabs').tabs({ selected: 0 });

        $('#rangeDatepick').datepick({
            numberOfMonths: [2,2],
            multiSelect: 999,
            changeMonth: false,
            changeYear: false,
            minDate: '<?php echo sfConfig::get( 'app_season_begin' ) ?>',
            maxDate: '<?php echo sfConfig::get( 'app_season_end' ) ?>',
            currentText: 'Календарь'
        });

        $("#rangeDatepick").datepick( 'setDate', dates );

        $(".datepick-days-cell-over").removeClass("datepick-days-cell-over");

        $("#photoSlider").jCarouselLite({
    		btnPrev: ".prevBtn",
            btnNext: ".nextBtn",
            vertical: true,
            circular: false,
            visible: <?php echo sfConfig::get( 'app_photo_slider_visible' ) < $lodging_photos->count() ? sfConfig::get( 'app_photo_slider_visible' ) : $lodging_photos->count() ?>,
            speed: 1000,
            easing: "<?php echo $photoSliderEasing[ rand( 0, count($photoSliderEasing)-1 ) ] ?>"
    	});

    	$("#tabs").css('visibility', 'visible');

    	$(".my_grid_3").css('visibility', 'visible');

        <?php if ( $lodging_photos->count() ): ?>
        $("a.lodging_photos").fancybox({
            'titlePosition': 'over'
        });
        <?php endif ?>

        $("table.datepick").mousemove(function() {
            disableDatepick();
        });

        $(".reserve").fancybox({
            'type'				: 'iframe',
    		'width'				: 600,
    		'height'			: 600,
            'autoScale'     	: false,
    		'href'              : '<?php echo url_for("@reserve") ?>'
    	});

    });

</script>
